
$MarkPatchAsExecutedClass = New-PSClass MarkPatchAsExecuted -inherit $PSSqlCommandClass {
	
	Constructor {
		Base $Args[0] $Args[1]
		
		$this.Command.CommandType = [System.Data.CommandType]::Text
		$this.Command.CommandText = @"
SET NOCOUNT ON;

DECLARE @OID bigint

SELECT @OID=OID
  FROM [DBFramework].[FileControl]
   WHERE FilePath = @FilePath

IF  (@@ROWCOUNT = 0)
BEGIN
	INSERT 
	  INTO [DBFramework].[FileControl]
           ( [FilePath]
           , [Applied]
           , [CheckSum])
	VALUES (@FilePath
           , GetDate()
           , @CheckSum)
END
ELSE BEGIN
	UPDATE [DBFramework].[FileControl]
	   SET CheckSum=@CheckSum
	     , Applied=GetDate()
	 WHERE OID=@OID
END
"@
		[void] $this.Command.Parameters.Add("@FilePath",$null)
		[void] $this.Command.Parameters.Add("@CheckSum",$null)
	}

  method Execute {
		$this.Command.Parameters["@FilePath"].Value = $Args[0]
		$this.Command.Parameters["@CheckSum"].Value = $Args[1]

		[void] $this.ExecuteScalar()
	}
}

